<% include("../public/fheader.html"){}%>
<div class="login-bg">
  <div class="login layui-anim layui-anim-up">
        <div class="message">管理登录</div>
        <div id="darkbannerwrap"></div>
        
        <form class="layui-form">
		   <ul>
            <li><input name="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" /></li>
            <li><input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input"/></li>
			<li><input name="capacha" lay-verify="required" placeholder="验证码" type="text" class="layui-input" style="width:54%;"><img src="/capacha" align="top" height="50" onclick="reflush(this)"/></li>
            <li class="layui-form-item"><button class="layui-btn" lay-submit="" lay-filter="login" style="width:100%;">登录</button></li>
			<li><a href="${'/admin/login/findpwd',url}">忘记密码？</a></li>
            </ul>
        </form>
  </div>
</div>

<% include("../public/ffooter.html"){}%>

<script>
  $(function  () {
            layui.use(['form', 'layer','jquery'], function(){
                $ = layui.jquery;
                var form = layui.form,layer = layui.layer;
              // layer.msg('玩命卖萌中', function(){
              //   //关闭后的操作
              //   });
              //监听提交

			  form.on('submit(login)',
                function(data) {
					try{
					$.post(jkas.url("/admin/login"),data.field,function(result)
					{
                     if(200==result.code)
					 {
                       location.href=jkas.url("/admin");
					  }
					  else
					  { let msg='';
					      switch(parseInt(result.code))
						   {case 201:
						     msg='密码不正确';
						     break;
							 case 202:
						     msg='用户不存在';
						     break;
							 case 203:
						     msg='用户名或密码为空';
						     break;
							 case 204:
						     msg='验证码不正确';
						     break;
							}
						  layer.alert("登录失败："+msg, {
                        icon: 5
                        });
					  }
				     },"json");
					 }catch(e){console.log(e);}
                    return false;
                });

              });
            });


       function reflush(obj)
		{obj.src="/capacha?"+new Date().getTime();
		}

        if (window.top != null && window.top.location != window.location) {
            window.top.location = window.location;
        }
</script>